﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Data;

namespace System.Data.DataSetGenerator
{
    /// <summary>
    /// Represents a description of a relationship in the dataset being generated.
    /// </summary>
    [XmlType("Relation")]
    [Serializable]
    public class RelationDescriptor
    {
        /// <summary>
        /// Initializes a new instance of the RelationDescriptor class.
        /// </summary>
        public RelationDescriptor()
        {
            Util.InitializeObject(this);
        }

        /// <summary>
        /// Gets or sets the name of the Relation in the DataSet
        /// </summary>
        [XmlAttribute]
        [DefaultValue("")]
        public String RelationName { get; set; }

        /// <summary>
        /// Indicates the type of a Relation
        /// </summary>
        [XmlAttribute]
        [DefaultValue(RelationTypeEnum.Both)]
        public RelationTypeEnum RelationType { get; set; }

        /// <summary>
        /// Gets or sets the UpdateRule property value of a ForeignKeyConstaint
        /// </summary>
        /// <remarks>Default value is System.Data.Rule.Cascade</remarks>
        [XmlAttribute]
        [DefaultValue(Rule.Cascade)]
        public Rule UpdateRule {get;set;}

        /// <summary>
        /// Gets or sets the DeleteRule property value of a ForeignKeyConstaint
        /// </summary>
        /// <remarks>Default value is System.Data.Rule.None
        /// </remarks>
        [XmlAttribute]
        [DefaultValue(Rule.None)]
        public Rule DeleteRule { get; set; }

        /// <summary>
        /// Gets or sets the correction action of the corresponding Relation in the DataSet.
        /// </summary>
        [XmlAttribute]
        [DefaultValue(SchemaObjectActionEnum.Modify)]
        public SchemaObjectActionEnum Action { get; set; }

        /// <summary>
        /// Gets or sets the name of a DataTable which is the parent of this Relation
        /// </summary>
        [XmlAttribute]
        [DefaultValue("")]
        public String PKDataTable { get; set; }

        /// <summary>
        /// Gets or sets a list of comma-separated names of DataColumn that are the parent columns of this DataRelation.
        /// </summary>
        [XmlAttribute]
        [DefaultValue("")]
        public String PKDataColumns { get; set; }

        /// <summary>
        /// Gets or sets the name of a DataTable which is the child of this Relation
        /// </summary>
        [XmlAttribute]
        [DefaultValue("")]
        public String FKDataTable { get; set; }

        /// <summary>
        /// Gets or sets a list of comma-separated names of DataColumn that are the child columns of this DataRelation.
        /// </summary>
        [XmlAttribute]
        [DefaultValue("")]
        public String FKDataColumns { get; set; }
    }
}
